cmake_minimum_required(VERSION 3.10)
project(snippets)
set(TARGET snippets)

# 精确收集源文件
file(GLOB SRC_FILES
    "main.cc"
    "smart_pointer/*.cc"
    "thread_pool/*.cc"
    "type_traits_demo/*.cc"
    "state_machine/v1/*.cc"
    "state_machine/double_buffer/*.cc"
)

# 生成可执行文件（必须先于add_custom_command）
add_executable(${TARGET} ${SRC_FILES})

# 有条件添加行为树
if(ENABLE_BEHAVIOR_TREE)
    file(GLOB BT_SOURCES "behavior_tree/*.cc")
    target_sources(${TARGET} PRIVATE ${BT_SOURCES})

    # # XML文件处理
    # install(FILES
    #     "${CMAKE_CURRENT_SOURCE_DIR}/behavior_tree/tree.xml"
    #     DESTINATION "${CMAKE_SOURCE_DIR}/share"
    # )

    configure_file(
        "${CMAKE_CURRENT_SOURCE_DIR}/behavior_tree/tree.xml"
        "${CMAKE_BINARY_DIR}/share/tree.xml"
        COPYONLY
    )
    
    target_link_libraries(${TARGET} behaviortree_cpp)
endif()